From fd463d65f9c18bb841b16d2545c953eb995166ee Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 30 Jan 2016 15:30:53 -0500 Subject: [PATCH] Revert "Downgrade term crate back down to 0.2 (from 0.4)." This reverts commit 75e0371ba0cd8ca235dea4e4178cf4c88dbf2e74. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/cargo/core/shell.rs | 23 +++++++++++++---------- src/cargo/util/errors.rs | 3 +++ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee26f7e1f..a2d750066 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,7 +25,7 @@ dependencies = [ "semver 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "term" -version = "0.2.14" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 5e3c52d59..ed3e7cb8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ regex = "0.1" rustc-serialize = "0.3" semver = "0.2.0" tar = "0.4" -term = "0.2" +term = "0.4" time = "0.1" toml = "0.1" url = "0.2" diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index cc764dcb6..14cc5f387 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -3,7 +3,7 @@ use std::io::prelude::*; use std::io; use term::color::{Color, BLACK, RED, GREEN, YELLOW}; -use term::{Terminal, TerminfoTerminal, color, Attr}; +use term::{self, Terminal, TerminfoTerminal, color, Attr}; use self::AdequateTerminal::{NoColor, Colored}; use self::Verbosity::{Verbose, Normal, Quiet}; @@ -193,22 +193,24 @@ impl Shell { Ok(()) } - fn fg(&mut self, color: color::Color) -> io::Result { + fn fg(&mut self, color: color::Color) -> CargoResult { let colored = self.colored(); match self.terminal { - Colored(ref mut c) if colored => c.fg(color), - _ => Ok(false), + Colored(ref mut c) if colored => try!(c.fg(color)), + _ => return Ok(false), } + Ok(true) } - fn attr(&mut self, attr: Attr) -> io::Result { + fn attr(&mut self, attr: Attr) -> CargoResult { let colored = self.colored(); match self.terminal { - Colored(ref mut c) if colored => c.attr(attr), - _ => Ok(false) + Colored(ref mut c) if colored => try!(c.attr(attr)), + _ => return Ok(false) } + Ok(true) } fn supports_attr(&self, attr: Attr) -> bool { @@ -220,13 +222,14 @@ impl Shell { } } - fn reset(&mut self) -> io::Result<()> { + fn reset(&mut self) -> term::Result<()> { let colored = self.colored(); match self.terminal { - Colored(ref mut c) if colored => c.reset().map(|_| ()), - _ => Ok(()) + Colored(ref mut c) if colored => try!(c.reset()), + _ => () } + Ok(()) } fn colored(&self) -> bool { diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index e2ba109f3..54934e10b 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -9,6 +9,7 @@ use curl; use git2; use rustc_serialize::json; use semver; +use term; use toml; use url; @@ -306,6 +307,7 @@ from_error! { url::ParseError, toml::DecodeError, ffi::NulError, + term::Error, } impl From> for Box { @@ -325,6 +327,7 @@ impl CargoError for toml::Error {} impl CargoError for toml::DecodeError {} impl CargoError for url::ParseError {} impl CargoError for ffi::NulError {} +impl CargoError for term::Error {} // ============================================================================= // Construction helpers -- 2.30.2